package yang.yu.sunny.domain.product;

import yang.yu.sunny.domain.NamedEntity;

import java.util.Objects;

/**
 * 产品
 * Created by yyang on 16/3/15.
 */
public class Product extends NamedEntity {

    //产品编号
    private String sn;

    private Long categoryId;

    protected Product() {
    }

    public Product(String name, Long categoryId) {
        super(name);
        this.categoryId = categoryId;
    }

    public String getSn() {
        return sn;
    }

    public void setSn(String sn) {
        this.sn = sn;
    }

    public Long getCategoryId() {
        return categoryId;
    }

    @Override
    public boolean equals(Object other) {
        if (this == other) {
            return true;
        }
        if (!(other instanceof Product)) {
            return false;
        }
        Product that = (Product) other;
        return Objects.equals(this.getSn(), that.getSn());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getSn());
    }

    @Override
    public String toString() {
        return getName();
    }
}
